import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
/*
 * Author:流水2005
 * Date:2015-12-1
 * Description:WebServer入口
 * 说明：web文件夹中的webserver.html为演示页面
 */
public class WebServer {
	
	public WebServer(){
		
		System.out.println("WebServer init.....");
	}
	//服务器启动
	public void Start(int port){
		
		try {
			//开启服务器监听端口
			ServerSocket serverSocket = new ServerSocket(port);
			//接收客户端连接
			while(true){
				Socket socket = serverSocket.accept();
				new Processor(socket).Run();
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	//主函数
	public static void main(String[] args) {
		// TODO Auto-generated method stub
       int port =80;
       if(args.length==1){
    	   
    	   port=Integer.parseInt(args[0]);
       }
		
       WebServer wb = new WebServer();
	   wb.Start(port);
		
	}

}
